<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UCenter Administrator's Control Panel</title>
<link rel="stylesheet" href="/public/images/admincp.css" type="text/css" media="all" />
<script src="/public/include/js/formFilter.js" type="text/javascript"></script> 
<meta content="Comsenz Inc." name="Copyright" />
</head>
<body><div id="append"></div>
<script type="text/javascript"> 
	function headermenu(ctrl) {
		ctrl.className = ctrl.className == 'otherson' ? 'othersoff' : 'otherson';
		var menu = document.getElementById('header_menu_body');
		if(!menu) {
			menu = document.createElement('div');
			menu.id = 'header_menu_body';
			menu.innerHTML = '<ul>' + document.getElementById('header_menu_menu').innerHTML + '</ul>';
			var obj = ctrl;
			var x = ctrl.offsetLeft;
			var y = ctrl.offsetTop;
			while((obj = obj.offsetParent) != null) {
				x += obj.offsetLeft;
				y += obj.offsetTop;
			}
			menu.style.left = x + 'px';
			menu.style.top = y + ctrl.offsetHeight + 'px';
			menu.className = 'togglemenu';
			menu.style.display = '';
			document.body.appendChild(menu);
		} else {
			menu.style.display = menu.style.display == 'none' ? '' : 'none';
		}
	}
</script>
 
	<div class="container">
		<h3 class="marginbot">编辑用户资料
			<?php echo '<a href="'.WEB_ROOT.'/admin/user/open" class="sgbtn">返回用户列表</a>'; ?>
							
					</h3>
					<div class="note"><p class="i">密码留空，保持不变。</p></div>
				<div class="mainbox">
			<form action="/admin/User/update-my-user" method="post"  onsubmit="return $.formValidator.pageIsValid('1')" >
				<?php echo $this->formHidden('id' , $this->user->id  );?>
				<table class="opt">
					<tr>
						<th>用户名:</th>
					</tr>
					<tr>
						<td>
							<input type="text"  value="<?php echo $this->user->username ?>" class="txt" readonly="readonly" />
						</td>
					</tr>
					<tr>
						<th>密　码:<a href="javascript:;" class="sgbtn" id="modify">修 改 </a></th>
					</tr>
					<tr>
						<td>
							<input type="password" name="password" id="password" value="" class="txt" />
						</td>
					</tr>
					<tr id="span_cp">
						<th>确认密码:</th>
					</tr>
					<tr>
						<td>
							<input type="password" name="confirmation" id="confirmation"  value="" class="txt" />
						</td>
					</tr>
					<tr>
						<th>Email:</th>
					</tr>
					<tr>
						<td>
							<input type="text" name="email" id="email" value="" class="txt" />
						</td>
					</tr>
					<tr>
						<th>角    色:</th>
					</tr>
					<tr>
						<td>
							<select name="role"  id="addrole">
								<?php 
									$roles = $this->user_roles->fetchAll(null , 'id desc');
									foreach($roles as $role){
										if($this->user->role == $role->name){
											echo '<option value="'.$role->name.'"  selected="selected">'.$role->name.'</option>';
										}else
											echo '<option value="'.$role->name.'">'.$role->name.'</option>';
									}
								?>
							</select>
						</td>
					</tr>
					<tr>
						<td ><span id="p_mark"></span></td>						
					</tr>
				</table>
				<div class="opt"><input type="submit" name="submit" value=" 提 交 " class="btn" tabindex="3" /></div>
			</form>
		</div>
	</div>
 
</body>
</html>
<script type="text/javascript">
	$(function(){
		$('input[id=password]').hide();
		$('input[id=confirmation]').parent().parent().hide();
		$('#span_cp').hide();
	});
	
	
	$('#modify').click(function(){
		var p_i = $("<input type='hidden' name='p_modified' value='1'/>");
		$('input[id=password]').toggle();
		$('input[id=password]').parent().children('span').toggle();
		$('input[id=confirmation]').parent().parent().toggle();
		$('#span_cp').toggle();
		$('#p_mark').children().remove();
		$('#p_mark').append(p_i);
		$('#modify').text()=='返回'?$('#modify').text('修 改'):$('#modify').text('返回');
		
		delete p_i;
	});
	
	
	$.formValidator.initConfig({autotip:true,tidymode:true,onerror:function(msg){alert(msg)}});

	$("#email").formValidator({onshow:"请输入邮箱",onfocus:"邮箱至少6个字符,最多100个字符",oncorrect:"恭喜你,你输对了",defaultvalue:"<?php echo $this->user->email ?>"}).inputValidator({min:6,max:100,onerror:"你输入的邮箱长度非法,请确认"}).regexValidator({regexp:"^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",onerror:"你输入的邮箱格式不正确"});
	
</script>
